package com.mashibing.juc.c_010;

/**
 * 子类重写父类synchronized方法，父子类中锁的是同一对象
 * @author: Yuanzt
 * @Date: 2021/3/24
 */
public class T {

    synchronized void m(){
        System.out.println(Thread.currentThread().getName() + " father's m start...");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " father's m end.");
    }

    public static void main(String[] args) {
        new TT().m();
    }
}

class TT extends T{

    @Override
    synchronized void m(){
        System.out.println(Thread.currentThread().getName() + " child's m start...");
        super.m();
        System.out.println(Thread.currentThread().getName() + " child's m end.");
    }
}
